﻿using AppTemplate.UI.Framework;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AppTemplate.UI.ViewModels
{
    public partial class FunctionViewModel:ViewModel
    {
        [RelayCommand]
        private void ShowAlert()
        {
            App.Alert("这是一个Alert");
        }

        [RelayCommand]
        private void ShowConfirm()
        {
            App.Confirm("这是一个Confirm?");
        }

        [RelayCommand]
        private void ShowStatusBar(object show)
        {
            
            App.ShowStatusBar(Convert.ToBoolean(show));
        }

        [RelayCommand]
        private void SetStatus()
        {
            App.ShowStatusBar(true);
            App.SetStatus("正在进行某项工作...");
        }

        [RelayCommand]
        private void SetProgress()
        {
            App.ShowStatusBar(true);
            App.ShowProgress(true, "正在操作...");
        }

        [RelayCommand]
        private async Task ReportProgress()
        {
            App.ShowStatusBar(true);
            App.SetStatus("正在下载...");

            int max = 100;
            await Task.Run(async () =>
            {
                int i = 0;
                while (i <= 100)
                {
                    App.ReportProgress(i, max);
                    await Task.Delay(20);
                    i++;
                }
            });
        }
    }
}
